#include "stdafx.h"
#include "GFPS.h"

GFPS GFPS::FPSControl;

GFPS::GFPS()
{
	OldTime = 0;
	LastTime = 0;

	SpeedFactor = 0;

	NumFrames = 0;
	Frames = 0;
}

GFPS::~GFPS()
{
}

void GFPS::OnLoop()
{
	    if(OldTime + 1000 < SDL_GetTicks()) 
		{       
			OldTime = SDL_GetTicks();  

			NumFrames = Frames;  

			Frames = 0;    
		}    

		//The SpeedFactor, each loop it will change its value
		SpeedFactor = ((SDL_GetTicks() - LastTime) / 1000.0f) * 32.0f;   

		LastTime = SDL_GetTicks();   

		Frames++;
}

int GFPS::GetFPS()
{
	return NumFrames;
}

float GFPS::GetSpeedFactor()
{
	return SpeedFactor;
}